﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<easyccms.BusinessLayer.Entities.Menu>>" %>

    <ul id="menu">

    <% foreach (easyccms.BusinessLayer.Entities.Menu item in Model)
       { %>
        <li><%= item.Name %></li>
        <li><ul>

            <%
           if (item.MenuItems!=null)
           foreach (easyccms.BusinessLayer.Entities.MenuItem menuItem in item.MenuItems.Where(x=>!x.Deleted))
           {
               %>
               <li>

               <% if(
                      string.IsNullOrEmpty(menuItem.ExternalUrl))
{
    if (menuItem.Article != null)
    { %>
    <%=

    Html.ActionLink(menuItem.Name, "Article", "Articles",
                    new {Area = "", id = menuItem.Article.ArticleId}, null)%>
    <%
    }else
    {
        Response.Write(menuItem.Name);
    }
}
                  else
{%>

    <%=Html.MenuExternalLink(menuItem.Name, menuItem.ExternalUrl)%>
    <%
}
                   //(string.IsNullOrEmpty(menuItem.ExternalUrl))
//                           ? Html.ActionLink(menuItem.Name, "Article", "Articles",
//                                                            new { Area = "", articleId = menuItem.Article.ArticleId }, null)
//                           : Html.MenuExternalLink(menuItem.Name, menuItem.ExternalUrl)
                   
                   %>
                   </li>
              <% } %>   
    </ul>
    </li>
          
    
    <% } %>

    </ul>
